#@head() #@header()
<title>融资需求管理</title>
#@aside("custser")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<div class="content-wrapper">
	<section class="content">
		<div class="nav-tabs-custom">
			#@custsermenu("repayment")
            <div class="tab-content">
              <div class="tab-pane active" id="tab_1">
				<div class="input-group margin" style="float:left">
					<label style="float:left;margin-left:20px;margin-top:5px">用户名:</label>
					<input id="mobile" style="width:150px;margin-left:20px;"  type="text" class="form-control"  >
					<label style="float:left;margin-left:20px;margin-top:5px">时间区间:</label>
					<input type="text" id="startime" class="form-control" onClick="WdatePicker()" style="width:120px;float:left;margin-left:10px;">
					<span style="float:left;margin:5px 5px 0 5px;">—</span>
					<input type="text" id="endtime" class="form-control" onClick="WdatePicker()" style="width:120px;float:left;margin-right:20px;">
					<label style="float:left;margin-left:5px;margin-top:5px">状态：</label>
					<select id="status" style="width:120px;float:left" class="form-control">
						<option value="">全部</option>
						<option value="process">还款中</option>
						<option value="success">已还款</option>
					</select>
					<label style="float:left;margin-left:20px;margin-top:5px">标的名称:</label>
					<input id="bidname" style="width:200px;margin-left:20px;"  type="text" class="form-control"  >
					<span style="margin-left:20px;float:left" class="input-group-btn">
					  <button id="bidseach" type="button" class="btn btn-info btn-flat">搜索</button>
					</span>
				</div>
				<div class="box-body">
					<table id="example1" class="table table-striped">
						<thead>
							<tr>
								<th>客户姓名</th>
								<th>客户号码</th>
								<th>标的名称</th>
								<th>计划还款时间</th>
								<th>实际还款时间</th>
								<th>还款方式</th>
								<th>应还本金</th>
								<th>应还利息</th>
								<th>还款总金额</th>
								<th>所属客服</th>
								<th>状态</th>	
								
							</tr>
						</thead>
						<tbody id="shenheall">

						</tbody>
					</table>
				</div>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id = "shall1"><a href="#">首页</a></li>
					<li id = "shall2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="shall5"></span>页 共<span id="shall6"></span>页</a></li>
					<li id = "shall3"><a href="#">下一页</a></li>
					<li id = "shall4"><a href="#">尾页</a></li>
				  </ul>
				</div>
              </div>
            <!-- /.tab-content -->
          </div>
	</section>
</div>
#@footer()
 <script id="shenhejieguo" type="text/x-jquery-tmpl">
	<tr> 
		<td>${name}</td>
		<td>${mobile}</td>
		<td>${bid_name}</td>
		<td>${repay_time}</td>
		<td>${actual_repay_time}</td>
		<td>${itemtype}</td>
		<td>${amount}元</td>
		<td>${interest}元</td>
		<td>${total}元</td>
		<td>${agent}</td>
		<td><span class="badge ${cla}">${aa}</span></td>
		
	</tr>
</script>
<script>
var startime = "";
var endtime ="";
var bidname = "";
var pageNumber = 1;
var mobile="";
var status="";
 $(document).ready(function(){ 
	$("#shenheall").empty();
	pageNumber = 1;
	shall(pageNumber,startime,endtime,bidname,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#shall1").click(function(){
	$("#shenheall").empty();
	pageNumber = 1;
	shall(pageNumber,startime,endtime,bidname,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#shall2").click(function(){
	if(pageNumber==1){
		alert("当前页是首页!");
	}else{
		$("#shenheall").empty();
		pageNumber = pageNumber-1;
		shall(pageNumber,startime,endtime,bidname,mobile,status);
		$("#shall5").html(pageNumber);
	}
});
$("#shall3").click(function(){
	if(pageNumber==totalPage){
		alert("当前页是尾页!");
	}else{
		$("#shenheall").empty();
		pageNumber = pageNumber +1;
		shall(pageNumber,startime,endtime,bidname,mobile,status);
		$("#shall5").html(pageNumber);
	}
});
$("#shall4").click(function(){
	$("#shenheall").empty();
	pageNumber = totalPage;
	shall(pageNumber,startime,endtime,bidname,mobile,status);
	$("#shall5").html(pageNumber);
});
$("#bidseach").click(function(){
	$("#shenheall").empty();
	startime = $("#startime").val();
	endtime = $("#endtime").val();
	bidname = $("#bidname").val();
	pageNumber = 1;
	mobile = $("#mobile").val();
	status = $("#status").val();
	shall(pageNumber,startime,endtime,bidname,mobile,status);
	$("#shall5").html(pageNumber);
});
function shall(pageNumber,startime,endtime,bidname,mobile,status){
	console.log(status);
	$.getJSON("/merit/repay?token=#(session.token??)&page="+pageNumber+"&size=14&start="+startime+"&end="+endtime+"&name="+bidname+"&mobile="+mobile+"&status="+status, function(shlist) {
		totalPage = shlist.data.page.totalPage;
		$("#shall6").html(totalPage);
		$.each(shlist.data.page.list, function(i, item){ 
			var aa=item.status;
			var cla="";
			if(aa=="process")
			{aa="还款中";cla="bg-yellow"}
			else if(aa=="success")
			{aa="已还款";cla="bg-light-blue"}
			if(item.type=="capital"){var itemtype="按月等额本金"}else if(item.type=="interest"){var itemtype="按月等额本息"}
			else if(item.type=="all"){var itemtype="到期归还本金及利息"}else if(item.type=="all"){var itemtype="按月还息，到期还本"}
			var interest = (item.interest+item.plus+item.jxq).toFixed(2);
			var jieguolist = {cla:cla,aa:aa,agent:item.agent,amount:item.amount,interest:interest,name:item.name,mobile:item.mobile,bid_name:item.bid_name,repay_time:item.repay_time,actual_repay_time:item.actual_repay_time,itemtype:itemtype,total:item.total};
			$("#shenhejieguo").tmpl(jieguolist).appendTo('#shenheall');
			
		});
	});
}
</script> 

</body>
</html>

